package com.ruoyi.chengkao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.chengkao.domain.CkExamSubject;
import com.ruoyi.chengkao.service.ICkExamSubjectService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 报考科类信息Controller
 * 
 * @author xiaosong
 * @date 2025-03-10
 */
@Api(tags = "成人高考-报考科类管理")
@RestController
@RequestMapping("/chengkao/examSubject")
public class CkExamSubjectController extends BaseController
{
    @Autowired
    private ICkExamSubjectService ckExamSubjectService;

    /**
     * 查询报考科类信息列表
     */
    @PreAuthorize("@ss.hasPermi('chengkao:examSubject:list')")
    @GetMapping("/list")
        @ApiOperation("成人高考报考科类管理 - 分页查询列表")
    public TableDataInfo list(CkExamSubject ckExamSubject)
    {
        startPage();
        List<CkExamSubject> list = ckExamSubjectService.selectCkExamSubjectList(ckExamSubject);
        return getDataTable(list);
    }

    //查询全部数据的接口
    @GetMapping("/all")
        @ApiOperation("成人高考报考科类管理 - 查询所有数据")
    public AjaxResult getAll()
    {
        List<CkExamSubject> list = ckExamSubjectService.selectCkExamSubjectAll();
        return success(list);
    }

    /**
     * 导出报考科类信息列表
     */
    @PreAuthorize("@ss.hasPermi('chengkao:examSubject:export')")
    @Log(title = "报考科类信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("成人高考报考科类管理 - 导出数据")
    public void export(HttpServletResponse response, CkExamSubject ckExamSubject)
    {
        List<CkExamSubject> list = ckExamSubjectService.selectCkExamSubjectList(ckExamSubject);
        ExcelUtil<CkExamSubject> util = new ExcelUtil<CkExamSubject>(CkExamSubject.class);
        util.exportExcel(response, list, "报考科类信息数据");
    }

    /**
     * 获取报考科类信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('chengkao:examSubject:query')")
    @GetMapping(value = "/{id}")
        @ApiOperation("成人高考报考科类管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ckExamSubjectService.selectCkExamSubjectById(id));
    }

    /**
     * 新增报考科类信息
     */
    @PreAuthorize("@ss.hasPermi('chengkao:examSubject:add')")
    @Log(title = "报考科类信息", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("成人高考报考科类管理 - 新增数据")
    public AjaxResult add(@RequestBody CkExamSubject ckExamSubject)
    {
        return toAjax(ckExamSubjectService.insertCkExamSubject(ckExamSubject));
    }

    /**
     * 修改报考科类信息
     */
    @PreAuthorize("@ss.hasPermi('chengkao:examSubject:edit')")
    @Log(title = "报考科类信息", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("成人高考报考科类管理 - 修改数据")
    public AjaxResult edit(@RequestBody CkExamSubject ckExamSubject)
    {
        return toAjax(ckExamSubjectService.updateCkExamSubject(ckExamSubject));
    }

    /**
     * 删除报考科类信息
     */
    @PreAuthorize("@ss.hasPermi('chengkao:examSubject:remove')")
    @Log(title = "报考科类信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
        @ApiOperation("成人高考报考科类管理 - 删除数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ckExamSubjectService.deleteCkExamSubjectByIds(ids));
    }
}
